<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>巡检任务列表</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/task_list_frm.css" />
	<link rel="stylesheet" href="../../css/vueComponent.css" />
    <style>
        body.active{
            background: url(../../image/icons/png/page_icon_empty.png) no-repeat center center;
        }
    </style>
</head>
<body>

    <script id="listView-template" type="text/x-dot-template">
        {{ for(var i=0, len=it.length; i < len; i++) {
          var model=it[i];
       		var time=model.date==null?model.inspecttime:model.date;
       		var starttime= model.starttime;
       		var endtime= model.endtime;
       		if(time!=null&&time!=''){
       		time=time.substring(0,time.lastIndexOf('-')).replace('-','年')+'月';
       		}else{
       		time='';
       		}

       		if(starttime!=null&&starttime!=''){
       		starttime=starttime.substring(0,starttime.lastIndexOf(':'));
       		}else{
       		starttime='';
       		}

       		if(endtime!=null&&endtime!=''){
       	endtime=endtime.substring(0,endtime.lastIndexOf(':'));
       		}else{
       		endtime='';
       		}
        }}
        <li tapmode="active" onclick="openWaitTask('{{=it[i].date != null ? it[i].date:""}}','{{=it[i].taskid != null ? it[i].taskid:""}}','{{=it[i].starttime != null ? it[i].starttime:""}}','{{=it[i].taskstatus != null ? it[i].taskstatus:""}}',
        '{{=it[i].stationname != null ? it[i].stationname:""}}','{{=it[i].stationcode != null ? it[i].stationcode:""}}','{{=it[i].stationid != null ? it[i].stationid:""}}','{{=it[i].operators != null ? it[i].operators:""}}',
        '{{=it[i].countyname != null ? it[i].countyname:""}}', '{{=it[i].taskstate != null ? it[i].taskstate:""}}', '{{=it[i].deviceid != null ? it[i].deviceid:""}}', '{{=it[i].allusername != null ? it[i].allusername:""}}');">
        		{{? api.pageParam.type=='XUNJIAN_TASK'}}
			<div class="liTop">
    			<div class="liTopFinishTitle">{{=it[i].taskname != null ? it[i].taskname:""}}</div>
    			<div class="liTopFinishTotal">项目：{{=it[i].projectcount != null ? it[i].projectcount:""}}</div>
			</div>
			<div class="liFinishMiddle">
				<div class="liDownPerson">巡检人：{{=it[i].taskusername != null ? it[i].taskusername:""}}</div>
				<div class="liDownBegin">开始：{{=it[i].date != null ? it[i].date:""}}</div>
				<div class="liDownEnd">结束：{{=it[i].inspectendtime != null ? it[i].inspectendtime:""}}</div>
			</div
			<div class="liFinishDown">
				<div class="liDownFinishBegin">开始：{{=it[i].starttime != null ? it[i].starttime:""}}</div>
				<div class="liDownFinishEnd">结束：{{=it[i].endtime != null ? it[i].endtime:""}}</div>
			</div>
			{{?? api.pageParam.type=='NEW_XUNJIAN_TASK'}}
						<div class="liTop">
    			<div class="liTopFinishTitle">{{=it[i].stationname != null ? it[i].stationname:""}}{{=it[i].checkresut != null ? "("+it[i].checkresut+")":""}}</div>
    			<div class="liTopFinishTotal">项目：{{=it[i].projectcount != null ? it[i].projectcount:""}}</div>
			</div>
			<div class="liFinishMiddle">
				<div class="liDownPerson" style="border-right: transparent;width: 50%">巡检人:{{=it[i].allusername != null ? it[i].allusername:""}}</div>
				<div class="liDownBegin" style="float: right;width: 45%">执行时间:{{=time}}</div>
			</div
			<div class="liFinishMiddle">
				<div class="liDownFinishBegin">实际开始:{{=starttime}}</div>
				<div class="liDownFinishEnd" style="float: right;text-align: right">实际结束:{{=endtime}}</div>
			</div>
			<div class="liFinishDown">
				<div class="liDownPerson" style="border-right: transparent;width: 50%;margin-top:0;">专业:{{=it[i].applymajor != null ? it[i].applymajor:""}}</div>
			</div
			 {{?}}
		</li>
        {{ } }}
    </script>
    <div id="" class="aui-content">
		<div id="app" v-cloak hide style="height: 40px;line-height:40px;background-color: white;position: relative;border-bottom: rgb(226,226,226) solid 1px;border-top: rgb(226,226,226) solid 1px" class="vue-dropdown">
			<label @click="active = !active" style="z-index: 10001;"><span style="margin-left: 20px">{{selectedItem.label}}</span><span class="dropdown-title" :class="[active?'active':'']"></span></label>
			<yt-mask :show.sync="active" @click-shadow="active = false" top="80px">
				<div class="list-container" v-show="active">
					<ul><li v-for="item in dataList" :key="item.id" @click="change(item,true)" :class="[value === item.value ? 'active' : '']"><span class="checked-badge" ></span>{{item.label}}</li></ul>
				</div>
			</yt-mask>
		</div>
    	<ul class="ccssoft_list" id="listView">

    	</ul>
    </div>
</body>
<script src="../../script/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/debug.js"></script>
<script type="text/javascript" src="../../script/constant.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/navigate.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/ccssoft/js/ccssoft-lite.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/vueComponent.js"></script>
<script type="text/javascript" src="../../script/client.api.js"></script>
<script type="text/javascript" src="../../script/aui-alert.js"></script>
<script type="text/javascript">


	var app = new Vue({
		el:'#app',
		mixins:[ORDER_OPTIONS_MIXIN],
		mounted(){
			this.init();
		},
		methods:{
			init(){
				this.active = false;
				this.change(this.dataList[0]);
			},
			change(item,refresh = false) {
				this.selectedItem = item;
				this.value = item.value;
				this.active = false;
				if(refresh){
					listView.setQueryOptions({
						sortCond:this.value
					});
					// alert(JSON.stringify(listView.queryOptions))
					listView.refresh();
				}
			}
		}
	});

	var beforeRefresh = function(obj,call){
		if(app){
			app.init();
			obj.setQueryOptions({
				sortCond:app.value
			});
		}
		call(true);
	}


	var listView = null;
    /**
     *打开待办任务的详情
     * readyStartTime 计划开始时间
     */
    function openWaitTask(readyStartTime, taskId, starttime, taskstatus,stationname,stationcode,stationid,operators,countyname,taskstate,deviceid,allusername) {
				var fromNotifition = "N";
        var user= $api.getStorage("user");
        openPage_taskProjectList(taskId, starttime, fromNotifition, taskstatus, readyStartTime,api.pageParam.start_status,"",taskstate,"","",stationname,stationcode,stationid,operators,countyname,'2',deviceid,"","","","",allusername);

//      api.openApp({
//                  iosUrl:"ChinaTower://userName="+user.loginname+"&siteCode="+deviceid+"&openclassname=CTResStationResultViewController"
//              },function(ret, err){
//                  if(ret){
//                  }else{
//                       MainClass.api_toast("QQ没有安装");
//                  }
//              });
    }

    apiready = function() {
    	reshuaxin();
    };
		/*
		*  dev:dxb
		*  date:2019/3/19
		*  decription:在巡检任务完成列表中，点击右上角历史，执行该方法，主要查询当前执行人执行过的巡检任务
		*/
		function reloadlist(){
			$api.setStorage("ifroolback","true");
			listView = new C.ApiListView({
						listName:'taskInfoList',
						fn : $client.getHisXJtask,
						limit:10000,
				beforeRefresh:beforeRefresh
				});
				listView.refresh();
		}
		function reshuaxin(){
			$api.rmStorage('ifroolback');
			$api.setStorage("indexId",api.pageParam.index_id);
    	if(api.pageParam.type=='XUNJIAN_TASK'){
    	listView = new C.ApiListView({
            listName:'taskInfoList',
            fn : $client.getFinishTaskList,
			beforeRefresh:beforeRefresh
        });
    	}else if(api.pageParam.type=='NEW_XUNJIAN_TASK'){
    	listView = new C.ApiListView({
				// wxx finish
            listName:'taskInfoList',
            fn : $client.getFinishNewTaskList,
						limit:10000,
			beforeRefresh:beforeRefresh
        });
    	}
        listView.refresh();
		}
		//----------------dxb-------------
    function cb_queryWaitTaskList(opts) {
    	 listView.setQueryOptions(opts);

         listView.refresh();
    }

    rollback = function(_taskId){
    	event.stopPropagation();
    	showlog('taskId = ' + _taskId );
    	var opts = {taskId:_taskId};
    	api.confirm({
			title : "巡检项目回退确认",
			msg : "确认回退该巡检项目吗？",
			buttons : ["确认", "取消"]
			}, function(ret, err) {
				if(ret.buttonIndex == 1){
					api.showProgress({
						title : '加载中',
						modal : false
					});
					$client.getTaskRollback(opts, function(ret, err) {
						if (ret) {
							if (ret.success) {
//								api.openWin({
//							        name: 'mainTaskList',
//							        url: 'mainTaskList.html',
//							        opaque: true,
//							        reload:true,
//							        bounces: false,
//							        vScrollBarEnabled: false,
//							        pageParam:{title:'未完成巡检任务'}
//							    });
							    window.setTimeout(function(){
							    	api.closeWin();
							    },200);
							} else {
								api.toast({msg: ret.data_info, location: 'middle'});
							}
						} else {
				            api.toast({msg: err.msg, location: 'middle'});
				        }
				        api.hideProgress();
					});
				}
			});
    }

</script>
</html>
